/*******************************************************************************
 * File:      phy_engine.h                                                     *
 * Function:  a simple physical engine                                         *
 * Author:    kvmaker                                                          *
 * Email:     kvmaker@gmail.com                                                *
 * Data:      24/Feb/2012                                                      *
 *                                                                             *
 * Copyright: kvmaker                                                          *
 *                                                                             *
 * Licensed under the Apache License, Version 2.0 (the "License");             *
 * you may not use this file except in compliance with the License.            *
 * You may obtain a copy of the License at                                     *
 *                                                                             *
 *    http://www.apache.org/licenses/LICENSE-2.0                               *
 *                                                                             *
 * Unless required by applicable law or agreed to in writing, software         *
 * distributed under the License is distributed on an "AS IS" BASIS,           *
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.    *
 * See the License for the specific language governing permissions and         *
 * limitations under the License.                                              *
 ******************************************************************************/
#ifndef __PHY_ENGINE_H__
#define __PHY_ENGINE_H__

/*******************************************************************************
 *                               INCLUDE                                       *
 ******************************************************************************/
#include "comdef.h"

/*******************************************************************************
 *                               DEFINE                                        *
 ******************************************************************************/
/*******************************************************************************
 *                               TYPEDEF                                       *
 ******************************************************************************/
typedef enum
{
    PHY_ENGINE_STATE_STOP = 0,
    PHY_ENGINE_STATE_RUN  = 1,
} PHY_ENGINE_STATE;

typedef struct 
{
    UINT32 weight;      /* Uint: kg         */

    UINT32 state;       
    UINT32 start_tick;  /* Uint: ms         */
    POINT  start_point; /* Uint: m          */
    VECTOR start_speed; /* Uint: m/s        */
    VECTOR force;       /* Uint: N, kg.m/s2 */
    VECTOR acc;         /* Uint: m/s2       */

    POINT  current_point;
    VECTOR current_speed;
} PHY_ENGINE; 

/*******************************************************************************
 *                               FUNCTION                                      *
 ******************************************************************************/
UINT32 phy_engine_init(PHY_ENGINE *engine, POINT *start, 
                       VECTOR     *speed,  VECTOR *force);
UINT32 phy_engine_start(PHY_ENGINE *engine);
UINT32 phy_engine_update(PHY_ENGINE *engine);
UINT32 phy_engine_restart(PHY_ENGINE *engine, VECTOR forece);
UINT32 phy_engine_stop(PHY_ENGINE *engine);

#endif /*__PHY_ENGINE_H__*/

